/**
 * ...
 * @author Thot
 */

function AnimationProxy()
{
	this.init( AnimationProxy.NAME, new Array() );
}

POO.extend( AnimationProxy, Proxy );


	// static
	
	AnimationProxy.NAME = "AnimationProxy";
	
	//public
	
	AnimationProxy.prototype.init = function( p_name, p_data )
	{
		this._super.init.apply( this, [ p_name, p_data ] );
		this.listenNotifications();
	};
	
	AnimationProxy.prototype.listenNotifications = function()
	{
		this.addNotificationListener( ApplicationNotification.LOAD_PROJECT_COMPLETE, this.onNotification );
	};

	AnimationProxy.prototype.onNotification = function( p_notificationType, p_data )
	{
		switch ( p_notificationType )
		{
			case ApplicationNotification.LOAD_PROJECT_COMPLETE:	
				this._parseAnimationData(); 
				break;
		}
	};
	
	AnimationProxy.prototype.getAnimationVOById = function( p_id )
	{
		var vo = null;
		var i = 0;
		var max = this._data.length;
		
		for( ; i < max; i++ )
		{
			vo = this._data[i];
			if( vo.name == p_id )
				return vo;
		}
		
		return null;
	};

	
	// private
	AnimationProxy.prototype._parseAnimationData = function()
	{
		var proxy = this.getFacade().getProxy( ApplicationProxy.NAME );
		var data = proxy.getAnimationsList();
		var i = 0;
		var max = data.length;
		var vo = null;
		var obj = null;
		
		for( ; i < max; i++ )
		{
			obj = data[i];
			vo = new AnimationVO();
			vo.name = obj.name;
			vo.width = obj.width;
			vo.height = obj.height;
			vo.animTime = obj.animTime;
			vo.frames = obj.frames;
			
			this._data.push( vo );
		}
	};
	

	